/* Copyright (C) 2010 Fredrique Samuels, fredriquesamuels@gmail.com 

 This program is free software: you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
 the Free Software Foundation, either version 3 of the License, or
 (at your option) any later version.

 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.

 You should have received a copy of the GNU General Public License
 along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */


#include "rectangle.h"


namespace tri {

std::ostream &operator<<(std::ostream& out, const tri::rectangle& m) {
    out<<"<Rectangle: ";
    for (int i = 0; i<4; i++) {
        out<<" "<<m.value[i];
    }
    out<<" >"<<std::endl;
    return out;
}


rectangle::rectangle(float left, float top, float right, float bottom) {
    value[0]=left;
    value[1]=top;
    value[2]=right;
    value[3]=bottom;
}

rectangle::rectangle(float v[4]) {
    value[0]=v[0];
    value[1]=v[1];
    value[2]=v[2];
    value[3]=v[3];
}
rectangle::~rectangle() {
}

void rectangle::get(float v[4]) {
    v[0] = value[0];
    v[1] = value[1];
    v[2] = value[2];
    v[3] = value[3];
}

const float* rectangle::getValue() {
    return value;
}

void rectangle::getRectValue(float v[8]) {
    v[0] = value[0];
    v[1] = value[1];

    v[2] = value[2];
    v[3] = value[1];

    v[4] = value[0];
    v[5] = value[3];

    v[6] = value[2];
    v[7] = value[3];
}

rectangle rectangle::copy() {
    float v[4];
    this->get(v);
    return rectangle(v[0], v[1], v[2], v[3]);
}

//rectangle rectangle::getSubRectangle(rectangle &rect){
//    const float * v = rect.getValue();
//    
//    rectangle rect(l*v[0]);
//}
void rectangle::translate(float x, float y) {
    value[0]+=x;
    value[1]+=y;
    value[2]+=x;
    value[3]+=y;
}

}

